<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<!DOCTYPE html>
<html>
<fmt:bundle basename="text">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title><fmt:message key="title"/></title>
        <link href="<%=basePath%>/images/favicon.ico" rel="shortcut icon" />
        <!-- Tell the browser to be responsive to screen width -->
        <meta
                content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
                name="viewport">
        <script src="<%=basePath%>/js/rem.js"></script>
        <link rel="stylesheet" href="<%=basePath%>/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="<%=basePath%>/css/font-awesome.min.css">
        <link rel="stylesheet" href="<%=basePath%>/dist/css/AdminLTE.min.css">
        <link rel="stylesheet" href="<%=basePath%>/dist/css/skins/_all-skins.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/viewer/viewer.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/iziModal/css/iziModal.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/flavr/flavr.css">
        <style type="text/css">

        </style>
        <link rel="stylesheet" href="<%=basePath%>/plugins/charts/css/device-detail.css">
    </head>
    <body class="hold-transition skin-blue sidebar-mini">
        <!-- Main content -->
        <section class="content">
                <div class="row">
                    <div class="col-md-3 left-part">
                        <div class="box box-primary">
                            <div class="box-body box-profile">
                                <h3 class="profile-username text-center"><a id="assetsName" target="_blank">${assetsName}</a></h3>
                                <p id="assetsNo" class="text-muted text-center">${assetsNo}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i>医院</span>
                                <p></p>
                                <p id="hospital" class="text-muted impor-info">${hospital}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i>型号</span>
                                <p></p>
                                <p id="model" class="text-muted impor-info">${model}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i>序列号</span>
                                <p></p>
                                <p id="sn" class="text-muted impor-info">${sn}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i>厂家</span>
                                <p></p>
                                <p id="manufacturerName" class="text-muted impor-info">${manufacturerName}</p>
                                <hr>
                                <span><i class="fa fa-user margin-r-5"></i> 报修人</span>
                                <p></p>
                                <p id="name" class="text-muted impor-info">${name}</p>
                                <hr>
                                <span><i class="fa fa-phone-square margin-r-5"></i>报修人电话</span>
                                <p></p>
                                <p id="phone" class="text-muted impor-info">${phone}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i> 紧急程度</span>
                                <p></p>
                                <p id="emergencyDegreeItem" class="text-muted impor-info">${emergencyDegreeItem}</p>
                                <hr>
                                <span><i class="fa fa-tasks margin-r-5"></i> 故障描述</span>
                                <p></p>
                                <p id="fault" class="text-muted impor-info">${fault}</p>
                                <hr>
                                <span><i class="fa fa-clock-o margin-r-5"></i> 故障时间</span>
                                <p></p>
                                <p id="faultTime" class="text-muted impor-info">${faultTime}</p>
                                <hr>
                                <span><i class="fa fa-clock-o margin-r-5"></i> 报修时间</span>
                                <p></p>
                                <p id="repairTime" class="text-muted impor-info">${repairTime}</p>
                                <hr>
                                <span><i class="fa fa-wrench margin-r-5"></i>维修内容</span>
                                <p></p>
                                <p id="repairContent" class="text-muted impor-info">${repairContent}</p>
                                <hr>
                                <span><i class="fa fa-clock-o margin-r-5"></i>确认修复时间</span>
                                <p></p>
                                <p id="completeTime" class="text-muted impor-info">${completeTime}</p>
                                <hr>


                                <span><i class="fa fa-clock-o margin-r-5"></i> 备注</span>
                                <p></p>
                                <p id="remark" class="text-muted impor-info">${remark}</p>
                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->

                    </div>
                    <!-- /.col -->
                    <div class="col-md-9 right-part">
                        <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs">
                                <li id="first-active" class="active"><a href="#timeline" data-toggle="tab">时间轴</a></li>
                                <li><a href="#repairPhots" data-toggle="tab">故障图片</a></li>
                                <li><a href="#repair" data-toggle="tab">维修处理</a></li>
                                <li><a href="#repairHistory" data-toggle="tab" onclick="queryRepairHistory()">维修历史</a></li>
                                <li><a href="#repairPart" data-toggle="tab" onclick="queryPartDispatch()">备件</a></li>
                                <li><a href="#repairCost" data-toggle="tab" onclick="queryCostDispatch()">费用</a></li>
                                <c:if test="${isInvoice == true}">
                                    <li><a href="#invoice" data-toggle="tab">发票</a></li>
                                </c:if>
                                <li><a href="#repairComment" data-toggle="tab" onclick="queryDispatchComment()">评价</a></li>
                                <c:if test="${yesOrNo == 1}"><!-- 医院能看到 -->
                                    <li><a href="#offer" data-toggle="tab" onclick="queryOffer()">报价信息</a></li>
                                </c:if>
                                <!-- <li style="display: none;"><a href="#file" data-toggle="tab" onclick="queryFileRepair()">维修文件</a></li> -->
                                <li id="second-active"><a href="#repairFile" data-toggle="tab" onclick="queryFileDispatch()">维修文件</a></li>
                                <%--<li><a href="#contractInfo" data-toggle="tab">合同信息</a></li>--%>
                            </ul>
                            <div class="tab-content">
                                <!-- 时间轴 -->
                                <div class="active tab-pane" id="timeline" style="min-height: 700px">
                                    <ul class="timeline timeline-inverse" id="timeAxis">
                                    </ul>
                                </div>
                                <!-- 维修详情  -->
                                <div class="tab-pane" id="repair" style="min-height: 600px"></div>
                                <!-- 维修工单 -->
                                <div class="tab-pane" id="file" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableFile"></table>
                                </div>
                                <!-- 派工工单 -->
                                <div class="tab-pane" id="repairFile" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableDispatchFile">
                                        <thead>
                                        <tr class="info">
                                            <th class='text-center text-muted'>文件类型</th>
                                            <th class='text-center text-muted'>操作</th>
                                            <th class='text-center text-muted'>签发日期</th>
                                            <th class='text-center text-muted'>结束时间</th>
                                            <th class='text-center text-muted'>文件大小</th>
                                            <th class='text-center text-muted'>备注</th>
                                            <th class='text-center text-muted'>上传时间</th>
                                        </tr>
                                        </thead>
                                        <tbody></tbody>
                                    </table>
                                </div>
                                <!-- 备件管理 -->
                                <div class="tab-pane" id="repairPart" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableDispatchPart"></table>
                                </div>
                                <!-- 费用管理 -->
                                <div class="tab-pane" id="repairCost" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableDispatchCost"></table>
                                </div>
                                <!-- 评价列表 -->
                                <div class="tab-pane" id="repairComment" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableDispatchComment"></table>
                                </div>

                                <!-- 报价列表 -->
                                <div class="tab-pane" id="offer" style="min-height: 700px">
                                    <table class="table table-bordered table-striped">
                                        <tr class="info">
                                            <th class="text-center text-muted" style="width: 35px">#</th>
                                            <th class="text-center text-muted">操作</th>
                                            <th class="text-center text-muted">编号</th>
                                            <th class="text-center text-muted">报价方</th>
                                            <th class="text-center text-muted">报价金额</th>
                                            <th class="text-center text-muted">报价时间</th>
                                            <th class="text-center text-muted">状态</th>
                                        </tr>
                                        <tbody id="tableOffer">

                                        </tbody>
                                    </table>
                                </div>

                                <!-- 故障图片 -->
                                <div class="tab-pane" id="repairPhots" style="min-height: 700px">
                                    <div class="docs-gally">
                                        <ul class="images clearfix" style="margin:0;padding:0;list-style:none;" id="phots"></ul>
                                    </div>
                                </div>

                                <!-- 历史维修 -->
                                <div class="tab-pane" id="repairHistory" style="min-height: 700px">
                                    <table class="table table-bordered table-striped" id="tableRepairHistory"></table>
                                </div>

                                <div class="tab-pane" id="contractInfo" style="min-height: 700px">
                                    <table id="contract-table" class="table table-bordered table-striped" style="width: 100%">
                                        <tr>
                                            <td colspan="8" class="control-label text-left text-muted info">基本信息</td>
                                        </tr>
                                        <tr>
                                            <td><label class="control-label text-muted text-left">合同号</label></td>
                                            <td><span id="contractNoText"></span></td>
                                            <td><label class="control-label text-muted text-left">合同名称</label></td>
                                            <td><span id="contractNameText"></span></td>
                                            <td><label class="control-label text-muted text-left">合同类型</label></td>
                                            <td><span id="categoryText"></span></td>
                                            <td><label class="control-label text-muted text-left">合同金额</label></td>
                                            <td><span id="contractAmountText"></span></td>
                                        </tr>
                                        <tr>
                                            <td><label class="control-label text-muted text-left">甲方</label></td>
                                            <td><span id="firstPartyText"></span></td>
                                            <td><label class="control-label text-muted text-left">乙方</label></td>
                                            <td><span id="maintainerName"></span></td>
                                            <td><label class="control-label text-muted text-left">签订人</label></td>
                                            <td><span id="signPersonText"></span></td>
                                            <td><label class="control-label text-muted text-left">联系人</label></td>
                                            <td><span id="contactPersonText"></span></td>
                                        </tr>
                                        <tr>
                                            <td><label class="control-label text-muted text-left">联系电话</label></td>
                                            <td><span id="contactPhoneText"></span></td>
                                            <td><label class="control-label text-muted text-left">签订单位</label></td>
                                            <td><span id="signUnitText"></span></td>
                                            <td><label class="control-label text-muted text-left">签订时间</label></td>
                                            <td><span id="signDateText"></span></td>
                                            <td><label class="control-label text-muted text-left">驻场人数</label></td>
                                            <td><span id="residentCountText"></span></td>
                                        </tr>
                                        <tr>
                                            <td><label class="control-label text-muted text-left">开始时间</label></td>
                                            <td><span id="startDateText"></span></td>
                                            <td><label class="control-label text-muted text-left">结束时间</label></td>
                                            <td><span id="endDateText"></span></td>
                                            <td><label class="control-label text-muted text-left">支付条款</label></td>
                                            <td><span id="paymentTermsText"></span></td>
                                            <td><label class="control-label text-muted text-left">合同内容</label></td>
                                            <td><span id="contractContentText"></span></td>
                                        </tr>
                                        <tr>
                                            <td><label class="text-muted text-left">区域</label></td>
                                            <td colspan="3"><span id="regionTextText"></span></td>
                                            <td><label class="control-label text-muted text-left">备注</label></td>
                                            <td colspan="3"><span id="remarkText"></span></td>
                                        </tr>
                                    </table>
                                    <p id="no-contract" class='hide' style='padding: 15px'>没有相关合同</P>
                                </div>


                                <!-- 发票信息 -->
                                <c:if test="${isInvoice == true}">
                                    <div class="tab-pane table-responsive" id="invoice" style="min-height: 600px">
                                        <table class="table table-striped table-bordered">
                                            <tbody>
                                            <tr class="info">
                                                <th class="text-center text-muted" style="width: 35px">#</th>
                                                <th class="text-center text-muted">发票编号</th>
                                                <th class="text-center text-muted">发票内容</th>
                                                <th class="text-center text-muted">发票金额</th>
                                                <th class="text-center text-muted">创建时间</th>
                                            </tr>
                                            <c:if test="${fn:length(invoiceList) > 0}">
                                                <c:forEach items="${invoiceList}" var = "list" varStatus="indexs">
                                                    <tr>
                                                        <td class='text-center text-muted'>${indexs.index+1}</td>
                                                        <td class='text-center text-muted'><a href="javascript:showInvoice(${list.id})">${list.invoiceNo}</a></td>
                                                        <td class='text-center text-muted'>${list.invoiceContent}</td>
                                                        <td class='text-center text-muted'>${list.alreadyPaidAmountStr}</td>
                                                        <td class='text-center text-muted'>${list.createTime}</td>
                                                    </tr>
                                                </c:forEach>
                                            </c:if>
                                            <c:if test="${fn:length(invoiceList) == 0}">
                                                <tr>
                                                    <td class='text-center text-muted' colspan="8">暂无数据</td>
                                                </tr>
                                            </c:if>
                                            </tbody>
                                        </table>
                                    </div>
                                </c:if>
                                <!-- iziModal模态窗口 -->
                                <div id="modal1" style="z-index:999999">
                                    <!-- 模态窗口的内容 -->
                                </div>

                                <!-- iziModal模态窗口 (备件列表)-->
                                <div id="partModal" style="display:none">
                                    <p></p>
                                    &nbsp;&nbsp;
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-striped" id="tablePart"></table>
                                    </div>
                                    <div class="box-footer text-right">
                                        <button data-iziModal-close class="btn btn-default submit">关闭</button>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </section>
    </div>
    <!-- ./wrapper -->
    <script src="<%=basePath%>/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="<%=basePath%>/bootstrap/js/bootstrap.min.js"></script>
    <script src="<%=basePath%>/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <script src="<%=basePath%>/plugins/fastclick/fastclick.js"></script>
    <script src="<%=basePath%>/dist/js/app.min.js"></script>
    <script src="<%=basePath%>/dist/js/demo.js"></script>
    <script src="<%=basePath%>/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
    <script src="<%=basePath%>/fileupload/fileinput.min.js"></script>
    <script src="<%=basePath%>/fileupload/fileinput.min.js"></script>
    <script src="<%=basePath%>/plugins/viewer/viewer.min.js"></script>
    <script src="<%=basePath%>/plugins/iziModal/js/iziModal.min.js"></script>
    <script src="<%=basePath%>/plugins/pdfobject/pdfobject.js"></script>
    <script src="<%=basePath%>/plugins/flavr/flavr.min.js"></script>
    </body>
    <script type="text/javascript">
        /* 获取URL中的参数 */
        var requestAttr = (function GetRequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = {};
            if (url.indexOf("?") !== -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for(var i = 0; i < strs.length; i ++) {
                    theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        })();
        /* 维修ID */
        var repairId = requestAttr.id || '';
        var assetsId = '';
        $(document).ready(function(){
            $('div[class^="toggleUp_"]').trigger("click");

            queryAssetsInfo();  // 设备信息 + 维修处理
            queryPhots();   // 故障图片

            // getContractInfo();   // 合同信息
            // 备件列表
            $("#partModal").iziModal({
                title:"备件列表",
                headerColor: '#222431',
                theme: '',  // light
                attached: '', // bottom, top
                icon: null,
                iconText: null,
                iconColor: '',
                rtl: false,
                width: 900,
                padding: 0,
                radius: 3,
                zindex: 1042,
                iframe: false,
                iframeHeight: 400,
                iframeURL: null,
                focusInput: false,
                group: '',
                loop: false,
                navigateCaption: true,
                navigateArrows: true, // closeToModal, closeScreenEdge
                history: false,
                restoreDefaultContent: false,
                autoOpen: false, // Boolean, Number
                bodyOverflow: false,
                fullscreen: true,
                openFullscreen: false,
                closeOnEscape: true,
                overlay: true,
                overlayClose: false,
                overlayColor: 'rgba(0, 0, 0, 0.4)',
                timeout: false,
                timeoutProgressbar: false,
                pauseOnHover: false,
                timeoutProgressbarColor: 'rgba(255,255,255,0.5)',
                transitionIn: 'comingIn',
                transitionOut: 'comingOut',
                transitionInOverlay: 'fadeIn',
                transitionOutOverlay: 'fadeOut',
                onFullscreen: function(){},
                onResize: function(){},
                onOpening: function(){},
                onOpened: function(){},
                onClosing: function(){},
                onClosed: function(){
                }
            });
            //判断页面是从哪里过来的
            if(window.location.href.indexOf("close") != -1){//表示是点关闭派工里面的查看按钮过来的
                $("#first-active").removeClass("active");
                $("#timeline").removeClass("active");
                $("#second-active").addClass("active");
                $("#repairFile").addClass("active");
                queryFileDispatch('${repairId}');
            } else {//表示是从详情按钮过来的

            }
        });

        /* 获取设备信息 + 维修处理 */
        function queryAssetsInfo() {
            $.ajax({
                url: '<%=basePath%>/charts/assets/repair/getRepairList',
                type: 'POST',
                dataType: 'json',
                data: {id: repairId},
                success: function (data) {
                    if (data.ret === 1) {
                        /* 设备信息 */
                        assetsId = data.data.assetsId;
                        $('#assetsName').html(data.data.assetsName || '')
                            .attr('_href', '<%=basePath%>/report/device/' + data.data.assetsId + '/full');
                        $('#assetsNo').html(data.data.assetsNo || '');
                        $('#hospital').html(data.data.hospital || '');
                        $('#model').html(data.data.model || '');
                        $('#sn').html(data.data.sn || '');
                        $('#manufacturerName').html(data.data.manufacturerName || '');
                        $('#name').html(data.data.name || '');
                        $('#phone').html(data.data.phone || '');
                        $('#emergencyDegreeItem').html(data.data.emergencyDegreeItem || '');
                        $('#fault').html(data.data.fault || '');
                        $('#faultTime').html(data.data.faultTime || '');
                        $('#repairTime').html(data.data.repairTime || '');
                        $('#repairContent').html(data.data.repairContent || '');
                        $('#completeTime').html(data.data.completeTime || '');
                        $('#remark').html(data.data.remark || '');
                        /* 维修处理 */
                        var list = data.data.repairList,
                            str = '';
                        for (var i = 0; i < list.length; i++) {
                            if (list[i].repairType) {
                                str += '<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo' + (i + 1) +
                                    '" onclick="getDispatchVisit(\'' + list[i].dispatchId + '\',\'' + i + 1 + '\');" class="collapsed" aria-expanded="false">' +
                                    '<div class="box-header with-border repair-info" style="width: 100%">' +
                                    '<p></p>' +
                                    '<p class="col-sm-12">' +
                                    '<span>创建时间</span>&nbsp;&nbsp;&nbsp;<span class="text-muted">' + (list[i].createTime || '') + '</span>' +
                                    '</p>' +
                                    '<p class="col-sm-12">' +
                                    getRepairType(list[i].repairType, list[i].pName) +
                                    '</p>' +
                                    '<p class="col-sm-12">' +
                                    '<span>备注</span>&nbsp;&nbsp;&nbsp;<span class="text-muted">' + (list[i].remark || '') + '</span>' +
                                    '</p>' +
                                    '</div>' +
                                    '</a>' +
                                    '<div id="collapseTwo' + (i + 1) + '" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">' +
                                    '<div class="box-body table-responsive no-padding repair-info" id="table_data' + i + 1 + '"></div>' +
                                    '</div>' +
                                    '<p></p>';
                            } else {
                                str += ' <div class="box-header"><span class="col-sm-12 text-muted text-center text-primary">无详情记录</span></div>';
                            }
                        }
                        function getRepairType(repairType, pName) {
                            if (repairType === 5001) {
                                return '<span>维修方式</span>&nbsp;&nbsp;&nbsp;<span class="text-muted">院内维修</span>';
                            } else if (repairType === 5002) {
                                return '<span>维修方式</span>&nbsp;&nbsp;&nbsp;<span class="text-muted">维修商修('+pName +')</span>';
                            } else if (repairType === 5003) {
                                return '<span>维修方式</span>&nbsp;&nbsp;&nbsp;<span class="text-muted">其他</span>';
                            }
                        }
                        $('#repair').html(str);
                    } else {
                        flavrShowByTime(data.msg, null, 'error', null);
                    }
                }
            });
        }

        timeAxis(repairId);
        /**
         * *************************************************************
         * 功能说明：查询时间轴信息
         * 创建人：乔春峰
         * 创建时间：2016年10月11日 21:24:21
         * *************************************************************
         */
        function textColor(text){
            var color = "#82ca2b";
            blueArr = ['医院确认'];
            greenArr = ['结束维修','离场','到场','预计上门'];
            orangeArr = ['报修处理','设备报修'];
            if(blueArr.indexOf(text) > -1){
                color = '#0084ff';
            }else if(orangeArr.indexOf(text) > -1){
                color = '#f9b229';
            }
            return color;
        }
        function timeAxis(repairId){
            var imgUrl;
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/queryRepairTimeLine',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                success:function(date){
                    $("#timeAxis").html("");
                    var togglerIndex='';
                    for (var i = 0; i < date.length; i++) {
                        var slidDiv = '',slidDivEnd='', color="#5082eb";
                        if(date[i].item == "上门信息"){
                            togglerIndex = i;
                            slidDiv = '<div class="toggleUp_'+togglerIndex+'" style="padding-left: 70px;color: #82ca2b;padding-bottom: 10px" onclick="toggleLi(this)"><span class="fa fa-angle-double-down" style="cursor: pointer"><span style="margin-left: 10px">'+date[i].detail+'</span></span></div>';
                            isHide = 'hide';
                            /*color="##82ca2b;cursor: pointer;";*/
                        }else{
                            isHide = '';
                        }
                        $("#timeAxis").append(slidDiv+"<li class='"+isHide+"'title='"+date[i].item+"_"+togglerIndex+"'>" +
                            "<i class='fa "+differentIcon(date[i].item)+"' style=';color: #fff;background:"+textColor(date[i].item)+"'>" +
                            "</i>" +
                            "<div class='timeline-item'>" +
                            "<h3 class='timeline-header' style='background: #fff'>" +
                            "<span style='color: #000'>"+date[i].time+"</span>" +
                            "</h3>" +
                            "<div class='timeline-body'><span style='color: "+textColor(date[i].item)+"'>【"+date[i].item+"】</span>"+date[i].detail+"</div>" +
                            "<div id='imgUrl"+i+"'></div>"+
                            "</div>" +
                            "</li>");
                        // 追加图片信息
                        if(date[i].imgUrl != null){
                            $("#imgUrl"+i+"").html("");
                            var result = date[i].imgUrl.split(",");
                            for(var j=0;j<result.length-1;j++){
                                $("#imgUrl"+i+"").append("<img style = 'width:100px;height:30px;' src='"+result[j]+"' alt='Visa'> &nbsp;");
                            }
                            $("#imgUrl"+i+"").viewer("destroy");
                            $("#imgUrl"+i+"").viewer();
                        }
                    }
                    // 结束
                    $("#timeAxis").append("<li><i class='fa fa-clock-o bg-gray' style='background: #5082eb'></i></li>");
                }
            });
        }
        function differentIcon(text){
            var icon = "";
            if(text=="医院确认"){
                icon = "fa-check"
            }else if(text=="结束维修"){
                icon = 'fa-square'
            }else if(text=="设备报修"){
                icon = 'fa-wrench'
            }else if(text=="报修处理"){
                icon = 'fa-pencil'
            }/*else if(text=="离场"){
			icon = 'fa-angle-double-down';
		}*/
            return icon;
        }
        function toggleLi(obj){
            className = obj.className;
            index = className.split("_")[1];

            if($("."+obj.className).children().hasClass("fa-angle-double-down")){
                $("."+obj.className).nextAll("li[title='离场_"+index+"']").slideUp();
                $(obj).nextAll("li[title='预计上门_"+index+"']").slideUp();
                $(obj).nextAll("li[title='到场_"+index+"']").slideUp();
                $("."+obj.className).children().removeClass("fa-angle-double-down");
                $("."+obj.className).children().addClass("fa-angle-double-right");
            }else{
                $("."+obj.className).nextAll("li[title='离场_"+index+"']").slideDown();
                $(obj).nextAll("li[title='预计上门_"+index+"']").slideDown();
                $(obj).nextAll("li[title='到场_"+index+"']").slideDown();
                $("."+obj.className).children().removeClass("fa-angle-double-right");
                $("."+obj.className).children().addClass("fa-angle-double-down")
            }
        }

        /**
         * *************************************************************
         * 功能说明：查询维修处理详情
         * 创建人：乔春峰
         * 创建时间：2016年10月11日 21:24:21
         * *************************************************************
         */
        function getDispatchVisit(dispatchId,number){
            var maintainenceTypeId = "";		// 解决方式
            var arrivalDeviceStatus = "";		// 到场状态
            var leaveDeviceStatus = "";		// 离场状态
            var positionMove ="";				// 位置移动
            var subsequentOperation ="";		// 后续操作
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/getDispatchVisitList',
                type:'POST',
                dataType:'json',
                data: {dispatchId:dispatchId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#table_data"+number).html("");
                    if(data==null || data==""){
                        $("#table_data"+number).html("<p><br/></p><p><span class='text-center text-primary col-sm-12'>无记录</span></p><br/><hr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            // 解决方式
                            if(data[i].maintainenceTypeId==null){
                                maintainenceTypeId == "";
                            }else if(data[i].maintainenceTypeId=="6001"){
                                maintainenceTypeId = "电话解决"
                            }else if(data[i].maintainenceTypeId=="6002"){
                                maintainenceTypeId = "上门解决"
                            }

                            // 到场状态
                            if(data[i].arrivalDeviceStatus==null || data[i].arrivalDeviceStatus=="undefined" || data[i].arrivalDeviceStatus==""){
                                arrivalDeviceStatus == "";
                            }else if(data[i].arrivalDeviceStatus=="4001" || data[i].arrivalDeviceStatus=="1"){
                                arrivalDeviceStatus = "正常"
                            }else if(data[i].arrivalDeviceStatus=="4002" || data[i].arrivalDeviceStatus=="2"){
                                arrivalDeviceStatus = "故障"
                            }else if(data[i].arrivalDeviceStatus=="4003" || data[i].arrivalDeviceStatus=="3"){
                                arrivalDeviceStatus = "宕机"
                            }

                            //离场状态
                            if(data[i].leaveDeviceStatus==null || data[i].leaveDeviceStatus=="undefined" || data[i].leaveDeviceStatus==""){
                                leaveDeviceStatus == "";
                            }else if(data[i].leaveDeviceStatus=="4001" || data[i].leaveDeviceStatus=="1"){
                                leaveDeviceStatus = "正常"
                            }else if(data[i].leaveDeviceStatus=="4002" || data[i].leaveDeviceStatus=="2"){
                                leaveDeviceStatus = "故障"
                            }else if(data[i].leaveDeviceStatus=="4003" || data[i].leaveDeviceStatus=="3"){
                                leaveDeviceStatus = "宕机"
                            }

                            // 位置移动
                            if(data[i].positionMove=="0"){
                                positionMove = "无"
                            }else if(data[i].positionMove=="1"){
                                positionMove = "到设备科"
                            }else if(data[i].positionMove=="2"){
                                positionMove = "到厂家"
                            }else if(data[i].positionMove=="3"){
                                positionMove = "到维修商"
                            }else if(data[i].positionMove=="4"){
                                positionMove="到维修中心";
                            }

                            // 后续操作
                            if(data[i].subsequentOperation=="0"){
                                subsequentOperation = "等备件"
                            }else if(data[i].subsequentOperation=="1"){
                                subsequentOperation = "派工升级"
                            }else if(data[i].subsequentOperation=="2"){
                                subsequentOperation = "无"
                            }

                            $("#table_data"+number).append("<p><br/>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 工程师&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].engineer || "")+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 解决方式&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+maintainenceTypeId+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 电话时间&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].callTime || "")+"</span></span>" +
                                "<br/>" +
                                "</p>" +
                                "<p>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 电话时长&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].callTimeLong || "")+"(小时)</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 到场时间&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].arrivalTime || "")+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 离场时间&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].leaveTime || "")+"</span></span>" +

                                "<br/>" +
                                "</p>" +
                                "<p>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 到场状态&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+arrivalDeviceStatus+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 离场状态&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+leaveDeviceStatus+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 工作时长&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].result || "")+"</span></span>" +
                                "<br/>" +
                                "</p>" +
                                "<p>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 派工时间&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].createTime || "")+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 派工人&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].name || "")+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 有无外援&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].outsideHelp==1?"有":"无")+"</span></span>" +
                                "<br/>" +
                                "</p>" +
                                "<p>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 位置移动&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+positionMove+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 后续操作&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+subsequentOperation+"</span></span>" +
                                "<span class='col-sm-4'><i class='fa fa-circle-o margin-r-5'></i> 旅行时间&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].travelTime/10 || '')+"（小时）</span></span>" +
                                "<br/></p>" +
                                "<p>" +
                                "<span class='col-sm-12'><i class='fa fa-circle-o margin-r-5'></i> 故障描述&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].fault || "")+"</span></span>" +
                                "<br/>" +
                                "</p>" +
                                "<p>" +
                                "<span class='col-sm-12'><i class='fa fa-circle-o margin-r-5'></i> 维修内容&nbsp;&nbsp;&nbsp;<span class='text-muted'>"+(data[i].repairContent || "")+"</span></span>" +
                                "<br/>" +
                                "</p><hr>");
                        }
                    }
                }
            });
        }

        // 查询维修工单
        function queryFileRepair(repairId){
            $.ajax({
                url:'queryFileRepair',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tableFile").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>#</th>"
                        + "<th class='text-center text-muted'>操作</th>"
                        + "<th class='text-center text-muted'>文件类型</th>"
                        + "<th class='text-center text-muted'>文件大小</th>"
                        + "<th class='text-center text-muted'>开始时间</th>"
                        + "<th class='text-center text-muted'>结束时间</th>"
                        + "<th class='text-center text-muted'>备注</th>"
                        /* + "<th class='text-center text-muted'>上传时间</th>" */
                        + "</tr>");
                    if(data==null || data==""){
                        $("#tableFile").append("<tr><td class='text-center text-primary' colspan='8' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            $("#tableFile").append("<tr>" +
                                "<td class='text-center'>"+(i+1)+"</td>" +
                                "<td class='text-center'><a href='#' onclick=\"preview('"+data[i].fileUrl+"','"+data[i].fileName+"');\">"+data[i].fileName+"</a></td>" +
                                "<td class='text-center'>"+data[i].fileType+"</td>" +
                                "<td class='text-center'>"+data[i].fileSizeStr+"</td>" +
                                "<td class='text-center'>"+(data[i].fileDateStart==null?"":data[i].fileDateStart)+"</td>" +
                                "<td class='text-center'>"+(data[i].fileDateEnd==null?"":data[i].fileDateEnd)+"</td>" +
                                "<td class='text-center'>"+(data[i].remark==null?"":data[i].remark)+"</td>" +
                                /* "<td class='text-center'>"+(data[i].createDate==null?"":data[i].createDate)+"</td>" + */
                                "</tr>");
                        }
                    }
                }
            });
        }

        // 查询派工工单
        function queryFileDispatch(){
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/queryFileDispatch',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tableDispatchFile tbody").html("");
                    if(data==null || data==""){
                        $("#tableDispatchFile tbody").append("<tr><td class='text-center text-primary' colspan='7' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            var fileName = data[i].fileName == null ? '' : data[i].fileName;
                            $("#tableDispatchFile tbody").append("<tr>" +
                                "<td class='text-center'>"+data[i].fileType+"</td>" +
                                "<td class='text-center'><a href='#' onclick=\"preview('"+data[i].fileUrl+"','"+data[i].fileName+"');\">"+fileName+"</a></td>" +
                                "<td class='text-center'>"+(data[i].fileDateStart==null?"":data[i].fileDateStart)+"</td>" +
                                "<td class='text-center'>"+(data[i].fileDateEnd==null?"":data[i].fileDateEnd)+"</td>" +
                                "<td class='text-center'>"+data[i].fileSizeStr+"</td>" +
                                "<td class='text-center'>"+(data[i].remark==null?"":data[i].remark)+"</td>" +
                                "<td class='text-center'>"+(data[i].createDate==null?"":data[i].createDate)+"</td>" +
                                "</tr>");
                        }
                    }
                }
            });
        }

        //查询费用管理列表
        function queryCostDispatch(){
            var repairMode;				// 维修方式
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/queryCostList',
                type:'POST',
                dataType:'json',
                data: {id:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tableDispatchCost").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>#</th>"
                        + "<th class='text-center text-muted'>派工信息</th>"
                        + "<th class='text-center text-muted'>金额</th>"
                        + "<th class='text-center text-muted'>处理时间</th>"
                        + "<th class='text-center text-muted'>备注</th>"
                        + "</tr>");
                    if(data==null || data==""){
                        $("#tableDispatchCost").append("<tr><td class='text-center text-primary' colspan='5' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            if (data[i].repairType== "5001"){
                                repairMode = "院内维修("+data[i].createTime+")";
                            }else if (data[i].repairType== "5002"){
                                repairMode = data[i].name+"("+data[i].createTime+")";
                            }else if (data[i].repairType== "5003"){
                                repairMode = "其它维修商("+data[i].createTime+")";
                            }

                            $("#tableDispatchCost").append("<tr>" +
                                "<td class='text-muted text-center'>"+(i+1)+"</td>" +
                                "<td class='text-muted text-center'>"+repairMode+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].amount==null?"":data[i].amount)+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].costCreateTime==null?"":data[i].costCreateTime)+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].remark==null?"":data[i].remark)+"</td>" +
                                "</tr>");
                        }
                    }
                }
            });
        }

        function scoreTotext(score){
            var text = ""
            switch (score){
                case 5:
                    text = "满意（5分）";
                    break;
                case 4:
                    text = "比较满意（4分）";
                    break;
                case 3:
                    text = "一般（3分）";
                    break;
                case 2:
                    text = "不太满意（2分）";
                    break;
                case 1:
                    text = "不满意（1分）";
                    break;
            }
            return text;
        }

        //查询评价列表
        function queryDispatchComment(){
            var repairType;				// 维修方式
            var score;					// 评分
            $.ajax({
                url:'<%=basePath%>/charts/assets/upkeep/queryComment',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tableDispatchComment").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>#</th>"
                        + "<th class='text-center text-muted'>维修方式</th>"
                        + "<th class='text-center text-muted'>维修商</th>"
                        + "<th class='text-center text-muted'>总体评分</th>"
                        + "<th class='text-center text-muted'>响应速度</th>"
                        + "<th class='text-center text-muted'>服务质量</th>"
                        + "<th class='text-center text-muted'>服务态度</th>"
                        + "<th class='text-center text-muted'>评价</th>"
                        + "<th class='text-center text-muted'>备注</th>"
                        + "</tr>");
                    if(data==null || data==""){
                        $("#tableDispatchComment").append("<tr><td class='text-center text-primary' colspan='9' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            if(data[i].repairType== "5001"){
                                repairType = "院内维修";
                            }else if (data[i].repairType== "5002"){
                                repairType = "维修商维修";
                            }else if (data[i].repairType== "5003"){
                                repairType = "其它维修商";
                            }
                            $("#tableDispatchComment").append("<tr>" +
                                "<td class='text-muted text-center'>"+(i+1)+"</td>" +
                                "<td class='text-muted text-center'>"+repairType+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].name==null?"":data[i].name)+"</td>" +
                                "<td class='text-muted text-center'>"+scoreTotext(data[i].score)+"</td>" +
                                "<td class='text-muted text-center'>"+scoreTotext(data[i].speedScore)+"</td>" +
                                "<td class='text-muted text-center'>"+scoreTotext(data[i].qualityScore)+"</td>" +
                                "<td class='text-muted text-center'>"+scoreTotext(data[i].attitudeScore)+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].comment==null?"":data[i].comment)+"</td>" +
                                "<td class='text-muted text-center'>"+(data[i].remark==null?"":data[i].remark)+"</td>" +
                                "</tr>");
                        }
                    }
                }
            });
        }

        //查询报价信息
        function queryOffer(){
            $("#tableOffer").html("");
            var bt = "";
            $.ajax({
                url:'<%=basePath%>/offer/list',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    var list = data.data;
                    if(list == null || list.length == 0){
                        $("#tableOffer").append("<tr><td class='text-center text-primary' colspan='7' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        var str = "";
                        for (var i = 0; i < list.length; i++) {
                            if(list[i].offerStatus == 0){
                                bt = "<button id='squaer' type='button' class='btn btn-info btn-xs' onclick='sendOa(${repairId},"+list[i].id+")' data-toggle='tooltip' title='发送OA审核'><i class='fa fa-send'></i></button>";
                            }else{
                                bt = "<button id='squaer' type='button' class='btn btn-xs disabled' data-toggle='tooltip' title='发送OA审核'><i class='fa fa-send'></i></button>";
                            }

                            switch(list[i].offerStatus){
                                case 0 : str="待申请";
                                    break;
                                case 1: str ="申请中";
                                    break;
                                case 2: str="申请通过";
                                    break;
                                case 3 : str = "申请不通过";
                                    break;
                            }

                            $("#tableOffer").append("<tr>" +
                                "<td class='text-muted text-center'>"+(i+1)+"</td>" +
                                "<td class='text-muted text-center'>"+ bt +"</td>" +
                                "<td class='text-muted text-center'>"+list[i].offerNumber+"</td>" +
                                "<td class='text-muted text-center'>"+list[i].offerParty+"</td>" +
                                "<td class='text-muted text-center'>"+list[i].money+"</td>" +
                                "<td class='text-muted text-center'>"+list[i].offerDate+"</td>" +
                                "<td class='text-muted text-center'>"+str+"</td>" +
                                "</tr>");
                        }
                    }
                }
            });
        }

        function scoreTotext(score){
            var text = ""
            switch (score){
                case 5:
                    text = "满意（5分）";
                    break;
                case 4:
                    text = "比较满意（4分）";
                    break;
                case 3:
                    text = "一般（3分）";
                    break;
                case 2:
                    text = "不太满意（2分）";
                    break;
                case 1:
                    text = "不满意（1分）";
                    break;
            }
            return text;
        }

        function queryPartDispatch(){
            var partText;
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/queryDispatchPart',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tableDispatchPart").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>详情</th>"
                        + "<th class='text-center text-muted'>备件说明</th>"
                        + "<th class='text-center text-muted'>备件品牌(新)</th>"
                        + "<th class='text-center text-muted'>备件名称(新)</th>"
                        + "<th class='text-center text-muted'>备件数量(新)</th>"
                        + "<th class='text-center text-muted'>备件型号(新)</th>"
                        + "<th class='text-center text-muted'>序列号(新)</th>"
                        + "<th class='text-center text-muted'>起始时间</th>"
                        + "<th class='text-center text-muted'>到期时间</th>"
                        + "</tr>");
                    if(data.dispatchPartList==null || data.dispatchPartList==""){
                        $("#tableDispatchPart").append("<tr><td class='text-center text-primary' colspan='9' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.dispatchPartList.length; i++) {
                            if(data.dispatchPartList[i].partStatus == 2){
                                partText = "更换";
                            }else if(data.dispatchPartList[i].partStatus == 3){
                                partText = "新增";
                            }else if(data.dispatchPartList[i].partStatus == 4){
                                partText = "收回";
                            }
                            $("#tableDispatchPart").append("<tr>" +
                                "<td class='text-muted text-center'><button id='square' type='button' class='btn btn-primary btn-xs' data-toggle='tooltip' onclick='getDispatchPart("+data.dispatchPartList[i].id+");' title='详情'> <i class='fa fa-file-text-o'></i> </button></td>" +
                                "<td class='text-muted text-center'>"+partText+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].partBrand==null?"":data.dispatchPartList[i].partBrand)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].partName==null?"":data.dispatchPartList[i].partName)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].partQuantity==null?"":data.dispatchPartList[i].partQuantity)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].partModel==null?"":data.dispatchPartList[i].partModel)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].number==null?"":data.dispatchPartList[i].number)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].startDate==null?"":data.dispatchPartList[i].startDate)+"</td>" +
                                "<td class='text-muted text-center'>"+(data.dispatchPartList[i].endDate==null?"":data.dispatchPartList[i].endDate)+"</td>" +
                                "</tr>");
                        }
                    }
                }
            });
        }

        // 查询故障图片
        function queryPhots(){
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/queryRepairView',
                type:'POST',
                dataType:'json',
                data: {id:repairId},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    $("#phots").html("");
                    if(data.phots=="" || data.phots == null){
                        $("#phots").html("<div class='box-header'><span class='col-sm-12 text-muted text-center text-primary'>无故障图片</span></div>");
                    }else{
                        var result = data.phots.split(",");
                        for(var i=0;i<result.length;i++){
                            $("#phots").append("<li style='float:left;width:25%;height:25%;margin:0 -1px -1px 0;border:1px solid transparent;overflow:hidden;'><img style='width:100%;' src='"+result[i]+"'></li>");
                        }
                        $('#phots').viewer("destroy");
                        $('#phots').viewer();
                    }
                }
            });
        }

        // 查询历史维修记录
        function queryRepairHistory(){
            $.ajax({
                type:'POST',
                url:'<%=basePath%>/charts/assets/repair/queryRepairAssets',
                data: {"assetsId":assetsId}, 	// 参数设备ID
                dataType:'json',
                success:function(data){
                    // 默认进来清空
                    $("#tableRepairHistory").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>故障时间</th>"
                        + "<th class='text-center text-muted'>故障描述</th>"
                        + "<th class='text-center text-muted'>报修人</th>"
                        + "<th class='text-center text-muted'>报修时间</th>"
                        + "<th class='text-center text-muted'>修复时间</th>"
                        + "</tr>");
                    if(data==null || data==""){
                        $("#tableRepairHistory").append("<tr><td class='text-center text-primary' colspan='5' >无记录</td></tr>");
                    }else{
                        // 循环追加数据
                        for (var i = 0; i < data.length; i++) {
                            for (var i = 0; i < data.length; i++) {
                                $("#tableRepairHistory").append("<tr>" +
                                    "<td class='text-muted text-center'>"+(data[i].faultTime==null?"":data[i].faultTime)+"</td>" +
                                    "<td class='text-muted text-left' style='white-space: normal !important;max-width: 300px;'>"+(data[i].fault==null?"":data[i].fault)+"</td>" +
                                    "<td class='text-muted text-center'>"+(data[i].name==null?"":data[i].name)+"</td>" +
                                    "<td class='text-muted text-center'>"+(data[i].repairTime==null?"":data[i].repairTime)+"</td>" +
                                    "<td class='text-muted text-center'>"+(data[i].completeTime==null?"":data[i].completeTime)+"</td>" +
                                    "</tr>");
                            }
                        }
                    }
                }
            });
        }

        //文件查看或者预览
        function preview(url,file){
            $("#modal1").iziModal({
                zindex:999999,
                headerColor: '#222431',
                title: '预览',
                subtitle: file,
                overlayClose: true,
                autoOpen: true,
                history:false,
                iframe : true,
                iframeURL:url,
                fullscreen: true,
                openFullscreen: false,
                onClosed:function(){
                    $('#modal1').iziModal('destroy');
                }
            });
            // $("#modal").iziModal('open');
        }

        // 下载文件
        function fileDownload(fileUrl,fileName,fileSuffix){
            var url = "<%=basePath%>";
            location.href= url+"/file/fileDownload?filePath="+fileUrl+"&fileName="+fileName;
        }

        function back(){
            window.history.back();
        }

        //查询合同信息
        function getContractInfo(){
            $.ajax({
                type: "POST",
                url: "<%=basePath%>/dispatchingAssets/queryContractInfoId",
                data: {repairId: "${repairId}"},
                success: function(data) {
                    if(data.ret){
                        if(data.data.contractInfoId){
                            $("#contract-table").removeClass("hide");
                            $("#no-contract").addClass("hide")
                            $.ajax({
                                type : "GET",
                                url : "<%=basePath%>/contract/get",
                                data :{"id": data.data.contractInfoId},
                                dataType : "json",
                                success: function(data) {
                                    $("#contractNoText").text(data.contractNo);
                                    $("#contractNameText").text(data.contractName);
                                    $("#firstPartyText").text(data.firstParty);
                                    $("#residentCountText").text(data.residentCount);
                                    $("#signDateText").text(data.signDate);
                                    $("#startDateText").text(data.startDate);
                                    $("#maintainerName").text(data.maintainerName);//乙方
                                    $("#endDateText").text(data.endDate);
                                    $("#contractAmountText").text(data.contractAmount/100);
                                    $("#signPersonText").text(data.signPerson);
                                    $("#signUnitText").text(data.signUnit);
                                    $("#contactPersonText").text(data.contactPerson);
                                    $("#regionTextText").text(data.regionText);
                                    $("#contactPhoneText").text(data.contactPhone);
                                    $("#contractContentText").text(data.contractContent);
                                    $("#categoryText").text(data.category);
                                    $("#paymentTermsText").text(data.paymentTerms);
                                    $("#remarkText").text(data.remark);
                                }
                            });
                        }else{
                            $("#contract-table").addClass("hide");
                            $("#no-contract").removeClass("hide")
                        }
                    }
                }
            });
        }

        /**
         * ************************************************
         * 功能说明：查询备件详情
         * 创建日期：2016年10月28日 12:50:41
         * 创建人：乔春峰
         * ************************************************
         */
        function getDispatchPart(id){
            $('#partModal').iziModal('open',this);
            var statusText;
            $.ajax({
                url:'<%=basePath%>/charts/assets/repair/getDispatchPart',
                type:'POST',
                dataType:'json',
                data: {id:id},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    // 默认进来清空
                    $("#tablePart").html("<tr class='info'>"
                        + "<th class='text-center text-muted'>说明</th>"
                        + "<th class='text-center text-muted'>价格</th>"
                        + "<th class='text-center text-muted'>备件名称(新)</th>"
                        + "<th class='text-center text-muted'>备件名称(旧)</th>"
                        + "<th class='text-center text-muted'>备件品牌(新)</th>"
                        + "<th class='text-center text-muted'>备件品牌(旧)</th>"
                        + "<th class='text-center text-muted'>备件型号(新)</th>"
                        + "<th class='text-center text-muted'>备件型号(旧)</th>"
                        + "<th class='text-center text-muted'>备件数量(新)</th>"
                        + "<th class='text-center text-muted'>备件数量(旧)</th>"
                        + "<th class='text-center text-muted'>序列号(新)</th>"
                        + "<th class='text-center text-muted'>序列号(旧)</th>"
                        + "</tr>");

                    if(data.partStatus == 2){
                        statusText = "更换";
                    }else if(data.partStatus == 3){
                        statusText = "新增";
                    }else if(data.partStatus == 4){
                        statusText = "收回";
                    }
                    $("#tablePart").append("<tr>" +
                        "<td class='text-muted text-center'>"+statusText+"</td>" +
                        "<td class='text-muted text-center'>"+(data.partPrice || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.partName || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.oldPartName || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.partBrand || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.oldPartBrand || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.partModel || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.oldPartModel || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.partQuantity || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.oldPartQuantity || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.number || '')+"</td>" +
                        "<td class='text-muted text-center'>"+(data.oldNumber || '')+"</td>" +
                        "</tr>");
                }
            });
        }

        function showInvoice(id){
            location.href="<%=basePath%>/invoice/invoiceDetail?id="+id;
        }

        // 发送报价信息给OA审核
        function sendOa(repairId,id){
            $.ajax({
                url:'<%=basePath%>/offer/sendOa',
                type:'POST',
                dataType:'json',
                data: {repairId:repairId,id:id},
                async: false,
                contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                success:function(data){
                    if(data.ret == 1){
                        queryOffer(repairId);
                        new $.flavr({content:data.msg,closeOverlay:true,closeEsc:true,autoclose:true,timeout:1500,buttons:[{text:'确定',style:'success',action:function(){}}]});
                    }else{
                        new $.flavr({content:data.msg,closeOverlay:true,closeEsc:true,autoclose:true,timeout:1500,buttons:[{text:'确定',style:'danger',action:function(){}}]});
                    }
                }
            });
        }
    </script>
</fmt:bundle>
</html>